package xyz.xiangyushui.util.dataBase.client.command.seedCommand;

import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import xyz.xiangyushui.util.dataBase.client.command.Command;
import xyz.xiangyushui.util.dataBase.client.command.CommandParser;

/**
 * definite the format of a seed command;
 * like: db:seed --table=user  
 * @author Ivan
 *
 */
public class SeedCommandParser extends CommandParser{
	private static final String seedCommandPattern="db:([a-zA-Z]+)( --([a-zA-Z]+)=([a-zA-Z]+)){0,1}";
	
	public SeedCommandParser(){
		super(seedCommandPattern);
	}

	@Override
	protected Command toCommand(Matcher m) {
		Command c=new Command();
		c.setCmd(m.group(1));
		Map<String,String> args=new HashMap<>();
		args.put(m.group(3), m.group(4));
		c.setArguments(args);
		return c;
	}
}
